package servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.Commande;
import beans.User;

import managers.AffichageManager;

/**
 * Servlet implementation class HomeServlet
 */
public class HomeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public HomeServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		Commande c = new Commande();
		if (request.getSession().getAttribute("panier") != null)
			c = (Commande) request.getSession().getAttribute("panier");
		request.setAttribute("affichage", AffichageManager.buildAffichageHome(
				(User) request.getSession().getAttribute("user"), c));
		request.getRequestDispatcher("./home.jsp").forward(request, response);
	}
}
